package com.inossem.warehousestorage_inossem.adapter.groupUpFrame;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.inossem.warehousestorage_inossem.R;

import java.util.List;

/**
 * 作者：wsy on 2018/1/23 14:41
 * <p>
 * 邮箱：445979770@qq.com
 */

public class GroupUpFrameItemListAdapter extends BaseAdapter {
    private Context mContext;
//    private List<UpFrameManageBean.DataBean.UpFrameListBean> mUpFrameList;
//    private GroupUpFrameItemActivity.GroupUpFrameItemListener mGroupUpFrameListener;
    private LayoutInflater inflater;
    private String mCondition;
    private List<String> list;


//    public GroupUpFrameItemListAdapter(List<String> list , Context context, List<UpFrameManageBean.DataBean.UpFrameListBean> upFrameList, String condition, GroupUpFrameItemActivity.GroupUpFrameItemListener upFrameManageListener) {
//        mContext = context;
//        mUpFrameList = upFrameList;
//        mCondition = condition;
//        mGroupUpFrameListener = upFrameManageListener;
//        inflater = LayoutInflater.from(context);
//        this.list = list;
//    }

    @Override
    public int getCount() {
        return list.size() + 1;
    }

    @Override
    public Object getItem(int position) {
        return list.get(position - 1);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
//        if (position == 0) {
//            convertView = inflater.inflate(R.layout.view_group_up_frame_list_first_item, null);
//            EditText condition = (EditText) convertView.findViewById(R.id.condition);
//            condition.setText(mCondition);
//            ImageView search = (ImageView) convertView.findViewById(R.id.search);
//            condition.addTextChangedListener(new QRCodeEditTextWatcher(condition) {
//                @Override
//                public void onScan(String text) {
//                    Utils.closeSoftKeyboard(mContext, condition);
//                    mGroupUpFrameListener.onNoDoubleClickListener(text);
//                }
//            });
//            search.setOnClickListener(new NoDoubleClickListener() {
//                @Override
//                public void onNoDoubleClick(View v) {
//                    mGroupUpFrameListener.onNoDoubleClickListener(condition.getText().toString());
//                }
//            });
//        } else {
////            UpFrameManageBean.DataBean.UpFrameListBean item = (UpFrameManageBean.DataBean.UpFrameListBean) getItem(position);
//            UpFrameManageBean.DataBean.UpFrameListBean item = new UpFrameManageBean.DataBean.UpFrameListBean();
//                    GroupUpFrameItemListAdapter.ViewHolder viewHolder;
//            if (convertView == null || (convertView != null && convertView.getTag() == null)) {
//                convertView = inflater.inflate(R.layout.view_group_up_frame_list, null);
//                viewHolder = new GroupUpFrameItemListAdapter.ViewHolder();
//                //初始化控件
//                initView(viewHolder, convertView);
//                convertView.setTag(viewHolder);
//            } else {
//                viewHolder = (GroupUpFrameItemListAdapter.ViewHolder) convertView.getTag();
//            }
//            //初始化数据
//            initData(mContext, viewHolder, convertView, item);
//
//        }
        return convertView;
    }

    private void initView(GroupUpFrameItemListAdapter.ViewHolder viewHolder, View view) {
        viewHolder.inStorageNumber = (TextView) view.findViewById(R.id.inStorageNumber);
        viewHolder.storageUnit = (TextView) view.findViewById(R.id.storageUnit);
        viewHolder.warehouseName = (TextView) view.findViewById(R.id.warehouseName);
        viewHolder.operationDate = (TextView) view.findViewById(R.id.operationDate);
        viewHolder.state = (TextView) view.findViewById(R.id.state);
    }

//    private void initData(Context context, GroupUpFrameItemListAdapter.ViewHolder viewHolder, View view, UpFrameManageBean.DataBean.UpFrameListBean item) {
//        viewHolder.inStorageNumber.setText("3600010465");
//        viewHolder.storageUnit.setText("1000000002");
//        viewHolder.warehouseName.setText("塔拉壕中心供应站");
//        viewHolder.operationDate.setText("2016-04-23");
//        viewHolder.state.setText("草稿");
//
//        //事件处理
//        view.setOnClickListener(new NoDoubleClickListener() {
//            @Override
//            public void onNoDoubleClick(View v) {
//                Intent intent = new Intent(context, GroupUpFrameOverviewActivity.class);
//                intent.putExtra(UpFrameExtra.REQUEST_NUMBER, item.getRequestNumber());
//                context.startActivity(intent);
//            }
//        });
//
//    }

    private class ViewHolder {
        private TextView inStorageNumber, storageUnit, warehouseName, operationDate, state;
    }
}
